package com.bobo.netty.client;

import io.netty.channel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
@ChannelHandler.Sharable
public class ChatClientHandler extends ChannelOutboundHandlerAdapter {
    private Logger LOGGER = LoggerFactory.getLogger(ChatClientHandler.class);
    @Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
        System.out.println("写出的消息="+msg);
        ctx.write(msg, promise);
        ctx.flush();
    }
    @Override
    public void read(ChannelHandlerContext ctx) throws Exception {
        System.out.println("读数据");
        ctx.read();
    }
}
